<!--{include file="header.html"}-->
<!-- END HEAD -->

<!-- BEGIN BODY -->
<body class="page-header-fixed">
<!-- BEGIN HEADER -->
<!--{include file="top.html"}-->
<!-- END HEADER -->

<!-- BEGIN CONTAINER -->
<div class="page-container row-fluid">
    <!-- 左边开始 -->
    <div class="page-sidebar nav-collapse collapse">
        <!-- BEGIN SIDEBAR MENU -->
        <!--{include file="menu.html"}-->
        <!-- END SIDEBAR MENU -->
    </div>
    <!-- 左边结束 -->

    <!-- BEGIN PAGE -->
    <div class="page-content">
        <!-- 右边开始-->
        <div class="container-fluid" >
            <!--右边标题导航开始-->
            <div class="row-fluid">
                <div class="span12">
                    <!-- BEGIN PAGE TITLE & BREADCRUMB-->
                    <!--{include file="nav.html"}-->
                    <!-- END PAGE TITLE & BREADCRUMB-->
                </div>

                <!--右边标题导航结束-->
                <!--右边中介内容开始-->
                <div class="content" >
                    <p class="fl"></p>
                    <div class="portlet box grey">
                        <!--标题-->
						<div class="portlet-title">
							<div class="caption"><i class="icon-reorder"></i>我的资源</div>
						</div>
                        <!--表格内容-->
						<div class="search_resources">
							<input id="seek" name="seek" type="text"  value="输入后请按回车搜索" title="输入后请按回车搜索" onKeyPress="if(event.keyCode==13){search_community(this)}" onKeyUp="backSearchOrRefresh(this)" onBlur="search_community(this)"/>
							<a class="hot-keyword" href="#">KTV</a><a class="hot-keyword" href="#">吃喝</a><a class="hot-keyword" href="#">唱歌</a><a class="hot-keyword" href="#">超市</a><a class="hot-keyword" href="#">洗浴</a>
						</div>
						<!--中间内容开始-->
						<table cellpadding="0" cellspacing="0" class="resources-table">
							<tbody>
								<tr>
									<td><input type="checkbox" value=""></td>
									<td>名称</td>
									<td>数量</td>
									<td>价格</td>
									<td>地址</td>
									<td>截止时间</td>
									<td>来源</td>
									<td>操作</td>
								</tr>
								<tr class="gray">
									<td><input type="checkbox" value=""></td>
									<td><a href="" class="resources-link">吸引力ATTktv东大店包厢劵</a></td>
									<td>10</td>
									<td>￥30</td>
									<td>成都吸引力ATTktv东大店</td>
									<td>2014-06-18</td>
									<td>创建</td>
									<td><a class="close-font">关闭</a></td>
								</tr>
								<tr>
									<td><input type="checkbox" value=""></td>
									<td><a href="" class="resources-link">吸引力ATTktv东大店包厢劵</a></td>
									<td>10</td>
									<td>￥30</td>
									<td>成都吸引力ATTktv东大店</td>
									<td>2014-06-18</td>
									<td>创建</td>
									<td><a class="close-font">关闭</a></td>
								</tr>
								<tr class="gray">
									<td><input type="checkbox" value=""></td>
									<td><a href="" class="resources-link">吸引力ATTktv东大店包厢劵</a></td>
									<td>10</td>
									<td>￥30</td>
									<td>成都吸引力ATTktv东大店</td>
									<td>2014-06-18</td>
									<td>创建</td>
									<td><a class="close-font">关闭</a></td>
								</tr>
								<tr>
									<td><input type="checkbox" value=""></td>
									<td><a href="" class="resources-link">吸引力ATTktv东大店包厢劵</a></td>
									<td>10</td>
									<td>￥30</td>
									<td>成都吸引力ATTktv东大店</td>
									<td>2014-06-18</td>
									<td>创建</td>
									<td><a class="close-font">关闭</a></td>
								</tr>
								<tr class="gray">
									<td><input type="checkbox" value=""></td>
									<td><a href="" class="resources-link">吸引力ATTktv东大店包厢劵</a></td>
									<td>10</td>
									<td>￥30</td>
									<td>成都吸引力ATTktv东大店</td>
									<td>2014-06-18</td>
									<td>创建</td>
									<td><a class="close-font">关闭</a></td>
								</tr>
								<tr>
									<td><input type="checkbox" value=""></td>
									<td><a href="" class="resources-link">吸引力ATTktv东大店包厢劵</a></td>
									<td>10</td>
									<td>￥30</td>
									<td>成都吸引力ATTktv东大店</td>
									<td>2014-06-18</td>
									<td>创建</td>
									<td><a class="close-font">关闭</a></td>
								</tr>
								<tr class="gray">
									<td><input type="checkbox" value=""></td>
									<td><a href="" class="resources-link">吸引力ATTktv东大店包厢劵</a></td>
									<td>10</td>
									<td>￥30</td>
									<td>成都吸引力ATTktv东大店</td>
									<td>2014-06-18</td>
									<td>创建</td>
									<td><a class="close-font">关闭</a></td>
								</tr>
								<tr>
									<td><input type="checkbox" value=""></td>
									<td><a href="" class="resources-link">吸引力ATTktv东大店包厢劵</a></td>
									<td>10</td>
									<td>￥30</td>
									<td>成都吸引力ATTktv东大店</td>
									<td>2014-06-18</td>
									<td>创建</td>
									<td><a class="close-font">关闭</a></td>
								</tr>
								<tr class="gray">
									<td><input type="checkbox" value=""></td>
									<td><a href="" class="resources-link">吸引力ATTktv东大店包厢劵</a></td>
									<td>10</td>
									<td>￥30</td>
									<td>成都吸引力ATTktv东大店</td>
									<td>2014-06-18</td>
									<td>创建</td>
									<td><a class="close-font">关闭</a></td>
								</tr>
								<tr>
									<td><input type="checkbox" value=""></td>
									<td><a href="" class="resources-link">吸引力ATTktv东大店包厢劵</a></td>
									<td>10</td>
									<td>￥30</td>
									<td>成都吸引力ATTktv东大店</td>
									<td>2014-06-18</td>
									<td>创建</td>
									<td><a class="close-font">关闭</a></td>
								</tr>
								<tr class="gray">
									<td><input type="checkbox" value=""></td>
									<td><a href="" class="resources-link">吸引力ATTktv东大店包厢劵</a></td>
									<td>10</td>
									<td>￥30</td>
									<td>成都吸引力ATTktv东大店</td>
									<td>2014-06-18</td>
									<td>创建</td>
									<td><a class="close-font">关闭</a></td>
								</tr>
								<tr>
									<td><input type="checkbox" value=""></td>
									<td><a href="" class="resources-link">吸引力ATTktv东大店包厢劵</a></td>
									<td>10</td>
									<td>￥30</td>
									<td>成都吸引力ATTktv东大店</td>
									<td>2014-06-18</td>
									<td>创建</td>
									<td><a class="close-font">关闭</a></td>
								</tr>
								<tr class="gray">
									<td><input type="checkbox" value=""></td>
									<td><a href="" class="resources-link">吸引力ATTktv东大店包厢劵</a></td>
									<td>10</td>
									<td>￥30</td>
									<td>成都吸引力ATTktv东大店</td>
									<td>2014-06-18</td>
									<td>创建</td>
									<td><a class="close-font">关闭</a></td>
								</tr>
								<tr>
									<td><input type="checkbox" value=""></td>
									<td><a href="" class="resources-link">吸引力ATTktv东大店包厢劵</a></td>
									<td>10</td>
									<td>￥30</td>
									<td>成都吸引力ATTktv东大店</td>
									<td>2014-06-18</td>
									<td>创建</td>
									<td><a class="close-font">关闭</a></td>
								</tr>								
							</tbody>
						</table>
						<!--底部条数信息-->
                        <div class="portlet-body fuelux">  
                            <div class="content event_list clearfix">
                                <div class="handle_paging clearfix">
                                    <div class="fl">
                                        <span class="all"><input name="check_all" id="check_all" type="checkbox" value="" />全选</span>
                                        <a class="btn green" href="javascript:void(0)" onClick="del_community_all()">批量关闭</a>
                                    </div>
                                    <!--{if $page_html}-->
                                    <div class="pagination fr">
                                        <ul>
                                            <!--{$page_html}-->
                                        </ul>
                                    </div>
                                    <!--{/if}-->
                                </div>
                            </div>
                            <!--中间内容结束-->
                        </div>
                    </div>
                </div>
                <!--右边中介内容结束-->
            </div>
            <!-- 右边结束-->
        </div>
        <!-- END PAGE -->
    </div>

    <!--公告弹出框-->
    <div id="prompt" style="width:800px;top:20%;display:none">
        <div class="title">提货地址<a id="close">关闭</a></div>
        <p style="padding-left: 20px; line-height: 30px; margin-top: 10px; " id="show_tip"><b style="color: #f00">温馨提示：</b>请输入15个字以内的公告</p>
        <div class="content">
            <div style="width:100%;height:40px;margin-bottom:10px">
                <div style="width:100%;height:100%;float:left">
                    <input id="id_activity" name="id_activity" type="hidden"/>
                    <input id="notice" placeholder="请输入要公告的内容" name="notice" type="text" maxlength="15" class="fl address_input" style="height: 30px;box-shadow: none;" />
                    <div class="prompt_button fr" style="padding: 0;"><a class="determine" style="margin: 0;">确定</a></div>
                </div>
            </div>
        </div>
    </div>
    <!--绑定电子卷弹出框-->
    <div id="pop_div" style="width:800px;height:360px;top:20%;display:none">
        <div class="title">绑定电子卷<a id="pop_close">关闭</a></div>
        <p style="padding-left: 20px; line-height: 30px; margin-top: 10px; " id="show_pop_tip"><b style="color: #f00">温馨提示：</b>一个活动可以绑定多种电子卷(单击即可选中)</p>
        <div class="content">
            <div style="width:100%;height:40px;margin-bottom:10px">
                <div style="width:100%;height:100%;float:left">
                    <input id="id_activity_eticket" name="id_activity_eticket" type="hidden"/>
                    <div id="box_list" style="height:150px;width:100%;" >
                        <ul id="left" style="display:block;float:left;height:100%;width:400px;border:1px solid #ddd;OVERFLOW-Y: auto; OVERFLOW-X:hidden">
                             <!--{foreach from = $elist item=li key=Key}-->
                                <li style="cursor:pointer;"><a title="<!--{$li.name}-->" data="<!--{$li.id_eticket}-->" class="eticket"><!--{$li.name}--></a></li>
                             <!--{/foreach}-->
                        </ul>
                        <div id="mid" style="float:left;height:100%;width:30px;line-height:150px;text-align:center;font-size:15px; font-weight:bold;">&hArr;</div>
                        <div id="eticketDIV" style="float:left;height:93%;width:315px;font-size:12px;color:#9C9C9C;border:1px solid #ddd;OVERFLOW-Y: auto; OVERFLOW-X:hidden; padding: 5px;">
                        </div>
                    </div>
                    <div class="prompt_button fr" style="margin-top:5px;padding: 0;"><a class="bindeticket" style="margin: 0;background:#35a948">确定</a></div>
                </div>
            </div>
        </div>
    </div>
    
    <div id="pop_up" style="display:none"></div>

    <!-- END CONTAINER -->

    <!-- BEGIN FOOTER -->
    <!--{include file="footer.html"}-->
    <!-- END PAGE LEVEL SCRIPTS -->

    <script>
        jQuery(document).ready(function() {
            App.init();
            UITree.init();

            $(".eticket").live('click',function(){
                var is_go = 0;
                var eid = $(this).attr('data');
                var ename = $(this).attr('title');
                var html = '<div class="eticket_list" id="eticket'+eid+'" style="cursor:pointer;margin:3px,5px ,0,0;" onclick="$(this).remove();">'+
                                '<input type="hidden" name="eid[]" value="'+eid+'"/>'+
                                    '<span class="checked">'+ename+
                                    '<a style="cursor:pointer;" onclick="$(this).parent().remove();" class="select2-search-choice-close"></a></span>'+
                            '</div>';
                $('input[name="eid[]"]').each(function(){
                    var val = $(this).val();
                    if(eid==val){
                        alert('该电子卷已经被选中了!');
                        is_go = 1;
                        return false;
                    }
                });
                if(is_go == 1){
                    return false;
                }
               $('#eticketDIV').append(html); 
            });
            
            $(".bindeticket").click(function(){
                var id_eticket = [];
                $("input[name='eid[]']").each(function(i){
                    id_eticket[i] = $(this).val();
                });
                if(!id_eticket.length){
                    alert('请选择需要绑定的电子卷!');
                    return false;
                }
                $.post('<!--{$url_prefix}-->community/bind_activ_eticket', {
                    'id_activity':$('#id_activity_eticket').val(),
                    'id_eticket':id_eticket
                }, function(msg){
                     $("#pop_div").hide();
                     $("#pop_up").hide();
                     if(msg.status){
                        alert('电子卷绑定成功！');
                     }else{
                        alert('电子卷绑定失败！');
                     }
                    
                }, 'json');   
            });

        });

        //发布公告
        $(".determine").click(function(){
            var notices = $('#notice').val();
            var notice = notices.replace(/(\r)*\n/g,"").replace(/\s/g,"");
            if(notice != ''){
                $.post('<!--{$url_prefix}-->community/publish_notice', {
                    'id_activity' : $('#id_activity').val(),
                    'notice' : notice
                }, function(data){
                    alert(data.msg);
                    $("#prompt").hide();
                    $("#pop_up").hide();
                    $('#notice').val('');
                    $('#show_notice'+$('#id_activity').val()).text(notice);
                }, 'json');
            }else{
                alert('还没有输入公告呢！');
            }
        });

        $("#close").click(function(){
            $("#prompt").hide();
            $("#pop_up").hide();
        });
        
        $("#pop_close").click(function(){
            $("#pop_div").hide();
            $("#pop_up").hide();
        });

        //展示发布公告的弹出层
        function show_notice_div(obj,aid){
            $("#prompt").show();
            $("#pop_up").show();
            $('#notice').val($(obj).parent().children('#show_notice'+aid).text());
            $('#id_activity').val(aid);
        }


        function setShare(title, url) {
            jiathis_config.title = title;
            jiathis_config.url = url;
        }
        var jiathis_config = {
            url: "",
            title: ""
        }

        $("#check_all").click(function () {//全选
            if($(this).attr('checked') != 'checked'){
                $("input[name ^= 'check_community']").attr("checked",false);
            }else{
                $("input[name ^= 'check_community']").attr("checked",true);

                $("input[name='check_community[]']").each(function(i){
                    if($(this).attr('disabled') == 'disabled'){
                        $(this).attr("checked",false);
                    }
                });
            }
        });

        $('input[name="check_community[]"]').click(function(){
            if($(this).attr('checked') != 'checked'){
                $("#check_all").attr("checked",false);
            }else{
                if($("input[name='check_community[]']:checked").length == $("input[name='check_community[]']").length){
                    $("#check_all").attr("checked",true);
                }
            }
        });

        //搜索提示效果
        $("input[name='seek']").click(function(){
            if($(this).val() == $(this).attr('title')){
                $(this).val('');
            }
        }).blur(function(){
            if($(this).val() == ''){
                $(this).val($(this).attr('title'));
            }
        });


        //删除互动活动列表信息
        function del_community(id_activity,offset){
            if(confirm("你确定要删除该活动信息吗？"))
            {
                var search_key = $('input[name="seek"]').val();
                $.post('<!--{$url_prefix}-->community/del_community', {
                    'id_activity': id_activity,
                    'search_key':search_key=='输入后请按回车搜索'?'':search_key,
                    'offset':offset,
                    'page_type':'one'
                }, function(data){
                    if(data.status == '0'){
                        alert('没权限执行此操作!');
                    }else
                        $('.event_list').html(data.data);
                }, 'json');
            }
        }


        //批量删除
        function del_community_all(){
            if($("input[name='check_community[]']:checked").length == 0){
                alert('你还没有选中需要删除的！');
                return false;
            }
            var activities = [];
            $("input[name='check_community[]']:checked").each(function(i){
                activities[i] = $(this).val();
            });

            if(confirm("你确定要删除这些活动信息吗？"))
            {
                var search_key = $('input[name="seek"]').val();
                $.post('<!--{$url_prefix}-->community/del_community', {
                    'search_key':search_key=='输入后请按回车搜索'?'':search_key,
                    'id_activity' : activities,
                    'page_type':'more'
                }, function(data){
                    $('.event_list').html(data.data);
                }, 'json');
            }
        }


        //开启  关闭 活动
        function update_state(obj,id_activity,num){
            $.post('<!--{$url_prefix}-->community/update_state', {
                'id_activity':id_activity,
                'state': num
            }, function(data){
                alert(data.data);
                var html = '';
                if(num == 2){
                    html = '<a href="javascript:void(0)" onclick="update_state(this,'+id_activity+',0)">关闭活动</a>';
                }else{
                    html = '<span>关闭活动</span>';
                }
                $(obj).parent().append(html);
                $(obj).remove();
            }, 'json');
        }

        //互动活动列表分页
        function community_list_page(offset){
            var search_key = $('input[name="seek"]').val();
            $.post('<!--{$url_prefix}-->community/list_community', {
                    'search_key':search_key=='输入后请按回车搜索'?'':search_key,
                    'offset':offset,
                    'page_type':1
            }, function(data){
                $('.event_list').html(data);
            }, 'text');
        }

        //搜索关键字
        function search_community(obj){
            var search_keys = $(obj).val();
            var search_key = search_keys.replace(/(\r)*\n/g,"").replace(/\s/g,"");
            if(search_key == ''){
//                alert('请输入你要搜索的文字内容！');
                return;
            }else{
                $.post('<!--{$url_prefix}-->community/search_community', {
                    'search_key':search_key=='输入后请按回车搜索'?'':search_key,
                    'offset':1
                }, function(data){
                    $('.event_list').html(data);
                }, 'text');
            }
        }
        //搜索返回刷新
        function backSearchOrRefresh(obj){
            var searchinput = $(obj).val();
            if(searchinput == ''){
                community_list_page(1);
            }
        }
        
        function bind_etickt(aid){
            if($(".eticket_list").length){
                $(".eticket_list").remove();
            }
            $("#pop_div").show();
            $("#pop_up").show();
            $('#id_activity_eticket').val(aid);
        }
        
    </script>
    <!-- END JAVASCRIPTS -->

</body>

<!-- END BODY -->

</html>